﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ValidationFramework.Configuration.Xml;
using System.IO;
using System.Xml;
using System.Reflection;
using ValidationFramework.Configuration.Fluent;

namespace ValidationFramework.Configuration
{
	public class XmlAddRuleExpression : IXmlAddRuleExpression
	{
		XmlConfigurationService _xmlService;
		Dictionary<PropertyKey, Rules> _propertyRules;
		Dictionary<FieldKey, Rules> _fieldRules;
		Dictionary<ParameterKey, Rules> _parameterRules;
		/// <summary>
		/// Initializes a new instance of the AddRuleExpression class.
		/// </summary>
		public XmlAddRuleExpression(XmlConfigurationService xmlService)
		{
			_xmlService = xmlService;
			_propertyRules = new Dictionary<PropertyKey, Rules>();
			_fieldRules = new Dictionary<FieldKey, Rules>();
			_parameterRules = new Dictionary<ParameterKey, Rules>();

		}

		// --- IXmlConfigExpression Members

		public void AddXmlFile(FileInfo xmlFileInfo)
		{
			_xmlService.AddXmlFile(xmlFileInfo);
		}

		public void AddXmlFile(string xmlFileUrl)
		{
			_xmlService.AddXmlFile(xmlFileUrl);
		}

		public void AddDirectory(DirectoryInfo directoryInfo)
		{
			_xmlService.AddDirectory(directoryInfo);
		}

		public void AddXmlString(string xml)
		{
			_xmlService.AddXmlString(xml);
		}

		public void AddXmlReader(XmlReader xmlReader)
		{
			_xmlService.Add(xmlReader);
		}

		public void AddUrl(string url)
		{
			_xmlService.AddXmlAtUrl(url);
		}

		public void AddUrl(Uri uri)
		{
			_xmlService.AddXmlAtUrl(uri);
		}

		public void AddDocument(XmlDocument xmlDocument)
		{
			_xmlService.AddDocument(xmlDocument);
		}

		public void AddInputStream(Stream xmlInputStream)
		{
			_xmlService.AddInputStream(xmlInputStream);
		}

		public void AddResourceFromAssembly(Assembly assembly, string path)
		{
			_xmlService.AddResource(path, assembly);
		}

		public void AddResourceFromAssembly(string assemblyName)
		{
			_xmlService.AddAssemblyResources(assemblyName);
		}

		public void AddResourceFromAssembly(Assembly assembly)
		{
			_xmlService.AddAssemblyResources(assembly);
		}
	}
}
